@@ -106,7 +106,7 @@ urlpatterns += [ |
||
106 | 106 |
url(r'^f/list$', group_views.flyimg_list_api, name='flyimg_list_api'), # 飞图列表 |
107 | 107 |
url(r'^f/detail$', group_views.flyimg_detail_api, name='flyimg_detail_api'), # 飞图详情 |
108 | 108 |
url(r'^f/comment/submit$', group_views.comment_submit_api, name='comment_submit_api'), # 飞图评论提交 |
109 |
- url(r'^f/comment/list$', group_views.comment_submit_api, name='comment_list_api'), # 飞图评论列表 |
|
109 |
+ url(r'^f/comment/list$', group_views.comment_list_api, name='comment_list_api'), # 飞图评论列表 |
|
110 | 110 |
url(r'^f/thumbup/submit$', group_views.thumbup_submit_api, name='thumbup_submit_api'), # 飞图点赞提交 |
111 | 111 |
url(r'^f/thumbup/list$', group_views.thumbup_list_api, name='thumbup_list_api'), # 飞图点赞列表 |
112 | 112 |
url(r'^f/thumbup/cancel$', group_views.thumbup_cancel_api, name='thumbup_cancel_api'), # 飞图点赞取消 |
@@ -350,7 +350,7 @@ def flyimg_detail_api(request): |
||
350 | 350 |
|
351 | 351 |
@logit |
352 | 352 |
def comment_submit_api(request): |
353 |
- """ 飞图评论提交/飞图评论列表 """ |
|
353 |
+ """ 飞图评论提交 """ |
|
354 | 354 |
group_id = request.POST.get('group_id', '') |
355 | 355 |
user_id = request.POST.get('user_id', '') |
356 | 356 |
to_uid = request.POST.get('to_uid', '') |
@@ -369,57 +369,60 @@ def comment_submit_api(request): |
||
369 | 369 |
except GroupPhotoInfo.DoesNotExist: |
370 | 370 |
return response(GroupPhotoStatusCode.GROUP_PHOTO_NOT_FOUND) |
371 | 371 |
|
372 |
- if comment: |
|
373 |
- # 群组照片评论记录创建 |
|
374 |
- PhotoCommentInfo.objects.create( |
|
375 |
- photo_id=photo_id, |
|
376 |
- user_id=user_id, |
|
377 |
- nickname=group_user.nickname, |
|
378 |
- avatar=group_user.avatar, |
|
379 |
- to_uid=to_uid, |
|
380 |
- comment=comment, |
|
372 |
+ # 评论内容校验 |
|
373 |
+ if not comment: |
|
374 |
+ return response(GroupPhotoStatusCode.COMMENT_CONTENT_EMPTY) |
|
375 |
+ |
|
376 |
+ # 群组照片评论记录创建 |
|
377 |
+ PhotoCommentInfo.objects.create( |
|
378 |
+ photo_id=photo_id, |
|
379 |
+ user_id=user_id, |
|
380 |
+ nickname=group_user.nickname, |
|
381 |
+ avatar=group_user.avatar, |
|
382 |
+ to_uid=to_uid, |
|
383 |
+ comment=comment, |
|
384 |
+ ) |
|
385 |
+ |
|
386 |
+ # 群组照片评论数更新 |
|
387 |
+ group_photo.comment_num += 1 |
|
388 |
+ group_photo.save() |
|
389 |
+ |
|
390 |
+ # Redis 群组照片数据缓存 |
|
391 |
+ set_group_photo_data(group_id) |
|
392 |
+ |
|
393 |
+ # Redis 群组照片评论列表缓存刷新 |
|
394 |
+ set_group_photo_comment_list(photo_id) |
|
395 |
+ |
|
396 |
+ r.sadd(GROUP_PHOTO_WATCHER_SET % photo_id, user_id) |
|
397 |
+ |
|
398 |
+ # 判断群组照片发布者是否已经被管理员移除/主动退出,如若移除/退出,则不给发布者提醒 |
|
399 |
+ if r.sismember(GROUP_USERS_PASSED_SET % group_photo.group_id, group_photo.user_id): |
|
400 |
+ UserMessageInfo.objects.create( |
|
401 |
+ from_uid=user_id, |
|
402 |
+ from_nickname=group_user.nickname, |
|
403 |
+ from_avatar=group_user.avatar, |
|
404 |
+ to_uid=group_photo.user_id, |
|
405 |
+ group_id=group_photo.group_id, |
|
406 |
+ photo_id=group_photo.photo_id, |
|
407 |
+ msg_type=UserMessageInfo.COMMENT, |
|
408 |
+ msg_title=u'评论', |
|
409 |
+ msg_content=comment, |
|
381 | 410 |
) |
382 | 411 |
|
383 |
- # 群组照片评论数更新 |
|
384 |
- group_photo.comment_num += 1 |
|
385 |
- group_photo.save() |
|
386 |
- |
|
387 |
- # Redis 群组照片数据缓存 |
|
388 |
- set_group_photo_data(group_id) |
|
389 |
- |
|
390 |
- # Redis 群组照片评论列表缓存刷新 |
|
391 |
- set_group_photo_comment_list(photo_id) |
|
392 |
- |
|
393 |
- r.sadd(GROUP_PHOTO_WATCHER_SET % photo_id, user_id) |
|
394 |
- |
|
395 |
- # 判断群组照片发布者是否已经被管理员移除/主动退出,如若移除/退出,则不给发布者提醒 |
|
396 |
- if r.sismember(GROUP_USERS_PASSED_SET % group_photo.group_id, group_photo.user_id): |
|
397 |
- UserMessageInfo.objects.create( |
|
398 |
- from_uid=user_id, |
|
399 |
- from_nickname=group_user.nickname, |
|
400 |
- from_avatar=group_user.avatar, |
|
401 |
- to_uid=group_photo.user_id, |
|
402 |
- group_id=group_photo.group_id, |
|
403 |
- photo_id=group_photo.photo_id, |
|
404 |
- msg_type=UserMessageInfo.COMMENT, |
|
405 |
- msg_title=u'评论', |
|
406 |
- msg_content=comment, |
|
407 |
- ) |
|
408 |
- |
|
409 |
- # 给所有关注者(评论/点赞)发送提醒,移除(评论/点赞)者和照片所有者 |
|
410 |
- watchers = get_group_photo_watchers(photo_id, [user_id, group_photo.user_id]) |
|
411 |
- for watcher in watchers: |
|
412 |
- UserMessageInfo.objects.create( |
|
413 |
- from_uid=user_id, |
|
414 |
- from_nickname=group_user.nickname, |
|
415 |
- from_avatar=group_user.avatar, |
|
416 |
- to_uid=watcher, |
|
417 |
- group_id=group_photo.group_id, |
|
418 |
- photo_id=group_photo.photo_id, |
|
419 |
- msg_type=UserMessageInfo.COMMENT, |
|
420 |
- msg_title=u'评论', |
|
421 |
- msg_content=comment, |
|
422 |
- ) |
|
412 |
+ # 给所有关注者(评论/点赞)发送提醒,移除(评论/点赞)者和照片所有者 |
|
413 |
+ watchers = get_group_photo_watchers(photo_id, [user_id, group_photo.user_id]) |
|
414 |
+ for watcher in watchers: |
|
415 |
+ UserMessageInfo.objects.create( |
|
416 |
+ from_uid=user_id, |
|
417 |
+ from_nickname=group_user.nickname, |
|
418 |
+ from_avatar=group_user.avatar, |
|
419 |
+ to_uid=watcher, |
|
420 |
+ group_id=group_photo.group_id, |
|
421 |
+ photo_id=group_photo.photo_id, |
|
422 |
+ msg_type=UserMessageInfo.COMMENT, |
|
423 |
+ msg_title=u'评论', |
|
424 |
+ msg_content=comment, |
|
425 |
+ ) |
|
423 | 426 |
|
424 | 427 |
return response(200, 'Comment Success', u'评论成功', { |
425 | 428 |
'comments': get_group_photo_comment_list(photo_id), |
@@ -427,6 +430,20 @@ def comment_submit_api(request): |
||
427 | 430 |
|
428 | 431 |
|
429 | 432 |
@logit |
433 |
+def comment_list_api(request): |
|
434 |
+ """ 飞图评论列表 """ |
|
435 |
+ photo_id = request.POST.get('photo_id', '') |
|
436 |
+ |
|
437 |
+ # 群组照片校验 |
|
438 |
+ if not GroupPhotoInfo.objects.filter(photo_id=photo_id).exists(): |
|
439 |
+ return response(GroupPhotoStatusCode.GROUP_PHOTO_NOT_FOUND) |
|
440 |
+ |
|
441 |
+ return response(200, 'Get Comment List Success', u'获取评论列表成功', { |
|
442 |
+ 'comments': get_group_photo_comment_list(photo_id), |
|
443 |
+ }) |
|
444 |
+ |
|
445 |
+ |
|
446 |
+@logit |
|
430 | 447 |
def thumbup_submit_api(request): |
431 | 448 |
""" 飞图点赞提交 """ |
432 | 449 |
group_id = request.POST.get('group_id', '') |
@@ -512,7 +529,6 @@ def thumbup_submit_api(request): |
||
512 | 529 |
@logit |
513 | 530 |
def thumbup_list_api(request): |
514 | 531 |
""" 飞图点赞列表 """ |
515 |
- group_id = request.POST.get('group_id', '') |
|
516 | 532 |
user_id = request.POST.get('user_id', '') |
517 | 533 |
photo_id = request.POST.get('photo_id', '') |
518 | 534 |
|
@@ -85,6 +85,8 @@ class GroupPhotoStatusCode(BaseStatusCode): |
||
85 | 85 |
# 点赞 |
86 | 86 |
THUMB_UP_NOT_FOUND = StatusCodeField(402220, 'Thumb Up Not Found', description=u'未点赞') |
87 | 87 |
DUPLICATE_THUMB_UP = StatusCodeField(402221, 'Duplicate Thumb Up', description=u'重复点赞') |
88 |
+ # 评论 |
|
89 |
+ COMMENT_CONTENT_EMPTY = StatusCodeField(402230, 'Comment Content Empty', description=u'评论内容为空') |
|
88 | 90 |
|
89 | 91 |
|
90 | 92 |
class OrderStatusCode(BaseStatusCode): |